
# define the config
SHELL = /bin/sh
CC = gcc
CFLAGS = -Wall -Werror -g -O2 -std=c99
LDFLAGS = -lm

SRC1 = who1.c
OBJS1 = $(SRC1:.c=.o)
TARGET1 :=$(SRC1:.c=.exe)
SRC2 = who2.c
OBJS2 = $(SRC2:.c=.o)
TARGET2 :=$(SRC2:.c=.exe)

%.o:%.c
	$(CC) -c $(CFLAGS) $<

.PHONY: all clean rebuild run

all:version $(TARGET1) $(TARGET2)
		
version:
	@$(CC) --version

$(TARGET1): $(OBJS1)
	@echo creat $(TARGET1)...
	$(CC) -o $(TARGET1) $^

$(TARGET2): $(OBJS2)
	@echo creat $(TARGET2)...
	$(CC) -o $(TARGET2) $^
		
clean:
	rm -f *.o *.exe *.bak $(TARGET1) $(TARGET2)
	
rebuild: clean all

run:
	@./$(TARGET1)
	
